#include <bits/stdc++.h>

using namespace std;

const int	LIM=1000;

int main(int argc,char ** argv)
{
	assert(argc>=3);
	int	n=atoi(argv[1]),m=atoi(argv[2]),i,T;
	vector<int>	vec;
	multiset<int>	S;
	random_device	seed;
	//mt19937		RND(-533769041);
	mt19937		RND((T=seed()));
	cerr << "Rand ID: " << T << endl;
	cout << n << ' ' << m << endl;
	for(i=1;i<=n;++i)vec.push_back(RND()%LIM),(cout << vec.back() << ' ');
	cout << endl;
	while(m--)
	{
		int	op=RND()%100;
		if(!m)op=0;
		if(op<20)
		{
			int	x=RND()%n+1,y=RND()%n+1;
			if(x>y)swap(x,y);
			cout << 1 << ' ' << x << ' ' << y << ' ' << RND()%LIM << endl;
			continue;
		}
		else if(op<40)
		{
			int	x=RND()%n+1,y=RND()%n+1;
			if(x>y)swap(x,y);
			cout << 2 << ' ' << x << ' ' << y << ' ' << RND()%n+1 << endl;
			continue;
		}
		else if(op<60)
		{
change:
			int	x=RND()%n+1,y=RND()%LIM;
			vec[x-1]=y;
			cout << 3 << ' ' << x << ' ' << y << endl;
			continue;
		}
		else if(op<80)
		{
			int	x=RND()%n+1,y=RND()%n+1;
			if(x>y)swap(x,y);
			int	z=RND()%LIM,j;
			for(j=1;j<=1000;++j)
			{ for(i=x-1;i<=y-1;++i)if(vec[i]<z)break;
				if(i!=y)break; z=RND()%LIM; }
			if(j>1000)goto change;
			cout << 4 << ' ' << x << ' ' << y << ' ' << z << endl;
			continue;
		}
		else if(op<100)
		{
			int	x=RND()%n+1,y=RND()%n+1;
			if(x>y)swap(x,y);
			int	z=RND()%LIM,j;
			for(j=1;j<=1000;++j)
			{ for(i=x-1;i<=y-1;++i)if(vec[i]>z)break;
				if(i!=y)break; z=RND()%LIM; }
			if(j>1000)goto change;
			cout << 5 << ' ' << x << ' ' << y << ' ' << z << endl;
			continue;
		}
	}
	return 0;
}

